﻿namespace Agent.Dialogs
{
    using Agent;
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class SendMessage : Window, IComponentConnector
    {
        private SynchronizationContext a;
        private ConnectionButton b;
        internal Image c;
        internal Label d;
        internal Label e;
        internal Label f;
        internal Label g;
        internal Label h;
        internal Label i;
        internal Button j;
        internal Button k;
        internal Label l;
        internal Label m;
        internal Label n;
        internal Border o;
        internal ScrollViewer p;
        internal TextBox q;
        internal Border r;
        internal ScrollViewer s;
        internal TextBox t;
        internal Label u;
        internal Label v;
        private bool w;

        public SendMessage(ConnectionButton A_0)
        {
            this.InitializeComponent();
            this.b();
            this.a = SynchronizationContext.Current;
            this.b = A_0;
        }

        [CompilerGenerated]
        private void a()
        {
            string[] a = WebRequestManager.h();
            if (((a != null) && (a.Length > 1)) && (a[1] != null))
            {
                <>c__DisplayClassb classb;
                this.a.Send(new SendOrPostCallback(classb.c), null);
            }
        }

        [DebuggerNonUserCode, EditorBrowsable(EditorBrowsableState.Never)]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((SendMessage) A_1).Loaded += new RoutedEventHandler(this.Window_Loaded);
                    return;

                case 2:
                    this.c = (Image) A_1;
                    return;

                case 3:
                    this.d = (Label) A_1;
                    return;

                case 4:
                    this.e = (Label) A_1;
                    return;

                case 5:
                    this.f = (Label) A_1;
                    return;

                case 6:
                    this.g = (Label) A_1;
                    return;

                case 7:
                    this.h = (Label) A_1;
                    return;

                case 8:
                    this.i = (Label) A_1;
                    return;

                case 9:
                    this.j = (Button) A_1;
                    this.j.Click += new RoutedEventHandler(this.btnSend_Click);
                    return;

                case 10:
                    this.k = (Button) A_1;
                    this.k.Click += new RoutedEventHandler(this.btnCancel_Click);
                    return;

                case 11:
                    this.l = (Label) A_1;
                    return;

                case 12:
                    this.m = (Label) A_1;
                    return;

                case 13:
                    this.n = (Label) A_1;
                    return;

                case 14:
                    this.o = (Border) A_1;
                    return;

                case 15:
                    this.p = (ScrollViewer) A_1;
                    return;

                case 0x10:
                    this.q = (TextBox) A_1;
                    return;

                case 0x11:
                    this.r = (Border) A_1;
                    return;

                case 0x12:
                    this.s = (ScrollViewer) A_1;
                    return;

                case 0x13:
                    this.t = (TextBox) A_1;
                    return;

                case 20:
                    this.u = (Label) A_1;
                    return;

                case 0x15:
                    this.v = (Label) A_1;
                    return;
            }
            this.w = true;
        }

        protected void b()
        {
            this.i.Content = e.c("Attention");
            this.f.Content = e.c("ConfigFile");
            this.h.Content = e.c("ConnectionLogMessage");
            this.e.Content = e.c("Login");
            this.d.Content = e.c("Message");
            this.g.Content = e.c("UserName");
            this.k.Content = e.c("Cancel");
            this.j.Content = e.c("Send");
            this.u.Content = e.c("SendMessageAttention");
            base.Title = e.c("SendMessageTitle");
            this.v.Content = "";
        }

        private void btnCancel_Click(object A_0, RoutedEventArgs A_1)
        {
            base.Close();
        }

        private void btnSend_Click(object A_0, RoutedEventArgs A_1)
        {
            <>c__DisplayClass5 class2;
            new Thread(new ParameterizedThreadStart(class2.g)) { IsBackground = true }.Start(new string[] { this.b.f(), this.t.Text, this.q.Text, this.n.Content.ToString() });
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.w)
            {
                this.w = true;
                Uri resourceLocator = new Uri("/TheSafety;component/dialogs/sendmessage.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void Window_Loaded(object A_0, RoutedEventArgs A_1)
        {
            this.a = SynchronizationContext.Current;
            new Thread(new ThreadStart(this.a)) { IsBackground = true }.Start();
            this.l.Content = AgentUser.a().d();
            if (this.b != null)
            {
                this.m.Content = this.b.f().Replace("_", "__");
                this.n.Content = this.b.l();
                this.t.Text = this.b.m();
            }
            if (AgentUser.a().b() == LicenseType.Limited)
            {
                this.j.IsEnabled = false;
            }
        }
    }
}

